package com.techsen.maven.plugins.version;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.command.tag.TagScmResult;

@Mojo(name = "tag")
public class TagMojo extends AbstractScmMojo {

    @Override
    public void execute() throws MojoExecutionException {
        try {
            TagScmResult result = this.scmManager.tag(this.getScmRepository(), this.getFileSet(), this.tagName, "commit for version: " + this.version);
            this.checkResult(result);
            this.getLog().info("create tag: " + this.tagName);
        } catch (ScmException e) {
            throw new MojoExecutionException(e.getMessage(), e);
        }
    }

}
